﻿function setAsHomePage(obj) {
    if (document.all) {
        obj.style.behavior = 'url(#default#homepage)';
        obj.setHomePage('http://tuoitre.vn');
    }

    return false;
}

// Menu Selected
function Set_Level1_Selected(id) {
    try
    {
        document.getElementById(id).className = "hover";
        document.getElementById(id + "_div").style.display = "block";
    }
    catch (err) { }
}

// Menu Selected
function SetSelectedTabMenu() {
    var url = window.location.href;

    if (url.toString().toLowerCase().match(/chinh-tri-xa-hoi/)) 
    {
        Set_Level1_Selected("mnu_1");
    }
    else if (url.toString().toLowerCase().match(/.vn\/the-gioi/)) 
    {
        Set_Level1_Selected("mnu_2");
    }
    else if (url.toString().toLowerCase().match(/.vn\/chinh-tri-xa-hoi\/phap-luat/)) 
    {
        Set_Level1_Selected("mnu_21");
    }
    else if (url.toString().toLowerCase().match(/nhip-song-tre/)) 
    {
        Set_Level1_Selected("mnu_3");
    }
    else if (url.toString().toLowerCase().match(/giao-duc/)) 
    {
        Set_Level1_Selected("mnu_4");
    }
    else if (url.toString().toLowerCase().match(/.vn\/kinh-te/)) 
    {
        Set_Level1_Selected("mnu_5");
    }
    else if (url.toString().toLowerCase().match(/van-hoa-giai-tri/)) 
    {
        Set_Level1_Selected("mnu_6");
    }
    else if (url.toString().toLowerCase().match(/du-lich/)) 
    {
        Set_Level1_Selected("mnu_9");
    }
    else if (url.toString().toLowerCase().match(/ban-doc/)) 
    {
        Set_Level1_Selected("mnu_7");
    }
    else if (url.toString().toLowerCase().match(/can-biet/)) 
    {
        Set_Level1_Selected("mnu_8");
    }
    else 
    {
        //Set_Level1_Selected("mnu_0");
    }
}

function date_time_home() {
    date = new Date;
    year = date.getFullYear();
    month = date.getMonth() + 1;
    d = date.getDate();
    day = date.getDay();
    days = new Array('CN', 'Thứ Hai', 'Thứ Ba', 'Thứ Tư', 'Thứ Năm', 'Thứ Sáu', 'Thứ 7');

    h = date.getHours();
    if (h < 10) {
        h = "0" + h;
    }

    m = date.getMinutes();
    if (m < 10) {
        m = "0" + m;
    }

    s = date.getSeconds();
    if (s < 10) {
        s = "0" + s;
    }

    result = '' + days[day] + ', ' + d + '/' + month + '/' + year + ', ' + h + ':' + m; // + ':' + s + ' (GMT+7)'

    $('#spanTime').html(result);
    setTimeout('date_time_home();', '6000');

    return true;
}

var articleNewIndex = 1;
// ArticleNews
function ChangeRandomArticleNews() {
    //var i = 1;

    for (var j = 1; j <= 12; j++) {
        if (document.getElementById("divFileRandom_" + j)) {
            document.getElementById("divFileRandom_" + j).style.display = "none";
        }
        else {
            break;
        }
    }

    if (document.getElementById("divFileRandom_" + articleNewIndex)) {
        document.getElementById("divFileRandom_" + articleNewIndex).style.display = "block";
    }

    /*
    i = i + 1;
    i = (i >= 1 && i <= 12) ? i : 1;

    if (document.getElementById("divFileRandom_" + i)) {
        document.getElementById("divFileRandom_" + i).style.display = "block";
    }
    i = i + 1;
    i = (i >= 1 && i <= 12) ? i : 1;

    if (document.getElementById("divFileRandom_" + i)) {
        document.getElementById("divFileRandom_" + i).style.display = "block";
    }
    */

    articleNewIndex = articleNewIndex + 1;
    articleNewIndex = (articleNewIndex >= 1 && articleNewIndex <= 12) ? articleNewIndex : 1;
}